package com.minhua.jijiehao2.view;

import android.content.Context;

import com.bigkoo.pickerview.OptionsPickerView;
import com.bigkoo.pickerview.TimePickerView;
import com.minhua.jijiehao2.R;

import java.util.List;

/**
 * @author moo
 * @date 2017/12/1.
 * @describe
 */

public class OptionsPickerViewUtil {
    private static OptionsPickerViewUtil INSTANCE;

    private OptionsPickerViewUtil() {
    }

    public synchronized static OptionsPickerViewUtil getInstance() {
        if (INSTANCE == null) {
            synchronized (OptionsPickerViewUtil.class) {
                if (INSTANCE == null) {
                    INSTANCE = new OptionsPickerViewUtil();
                }
            }
        }
        return INSTANCE;
    }


    private OptionsPickerView optionsPickerView;

    public void initOptionsPickerView(Context context, List<String> list, OptionsPickerView.OnOptionsSelectListener listener) {
        optionsPickerView = new OptionsPickerView.Builder(context, listener)
                .setCancelColor(context.getResources().getColor(R.color.mainRed))
                .setSubmitColor(context.getResources().getColor(R.color.mainRed))
                .build();
        optionsPickerView.setPicker(list);
    }

    public void showType() {
        optionsPickerView.show();
    }

    private TimePickerView timePickerViewDaily;

    public void initTimerPickerView(Context context, TimePickerView.OnTimeSelectListener listener) {
        timePickerViewDaily = new TimePickerView.Builder(context, listener)
                .setType(new boolean[]{false, false, true, false, false, false})
                .isCenterLabel(false)
                .setCancelColor(context.getResources().getColor(R.color.mainRed))
                .setSubmitColor(context.getResources().getColor(R.color.mainRed))
                .build();
    }

    public void showTimer() {
        timePickerViewDaily.show();
    }

    private TimePickerView timePickerViewNotice;

    public void initNoticeView(Context context, TimePickerView.OnTimeSelectListener listener) {
        timePickerViewNotice = new TimePickerView.Builder(context, listener)
                .setType(new boolean[]{false, true, true, true, true, false})
                .isCenterLabel(false)
                .setCancelColor(context.getResources().getColor(R.color.mainRed))
                .setSubmitColor(context.getResources().getColor(R.color.mainRed))
                .build();
    }

    public void showNotice() {
        timePickerViewNotice.show();
    }

}
